﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AgilePlannerDT.Data.Impl
{
    class CardPositionSynchronizationDataObject:CardPoistionSynchronization
    {
        long cardID;
        double currentX, currentY, rotationAngle;
        public CardPositionSynchronizationDataObject() : this(0, 0, 0, 0) { }

        public CardPositionSynchronizationDataObject(long targetID, double targetX, double targetY, double targetAngle)
        {
            this.cardID = targetID;
            this.currentX = targetX;
            this.currentY = targetY;
            this.rotationAngle = targetAngle;
        }

        #region IXmlSerializable Members


        public void ReadXml(System.Xml.XmlReader reader)
        {
            this.rotationAngle = Convert.ToDouble(reader.GetAttribute("RotationAngle"));
            this.currentX = Convert.ToDouble(reader.GetAttribute("CardX"));
            this.currentY = Convert.ToDouble(reader.GetAttribute("CardY"));
            this.cardID = (long)(Convert.ToDouble(reader.GetAttribute("CardID")));
                 
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("CardDrag");
            writer.WriteAttributeString("CardX", this.currentX.ToString());
            writer.WriteAttributeString("CardY", this.currentY.ToString());
            writer.WriteAttributeString("RotationAngle", this.rotationAngle.ToString());
            writer.WriteAttributeString("CardID", this.cardID.ToString());
            writer.WriteEndElement();
        }

        #endregion





        #region IXmlSerializable Members

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region CardPoistionSynchronization Members

        public long CardID
        {
            get { return this.cardID; }
        }

        public double X
        {
            get {return  this.currentX; }
        }

        public double Y
        {
            get { return this.currentY; }
        }

        public double RotationAngle
        {
            get { return this.rotationAngle; }
        }

        #endregion
    }
}
